package com.seewo.dubbo.debugger.admin.entity;

import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.seewo.dubbo.debugger.admin.common.validate.group.Update;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.NotBlank;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

/**
 * <p>
 *
 * </p>
 *
 * @author chenliangliang
 * @since 2018-07-25
 */
@Data
@Accessors(chain = true)
@TableName("t_parameter")
public class Parameter implements Serializable {

    private static final long serialVersionUID = 4153790263261322362L;

    @TableId(value = "c_id", type = IdType.AUTO)
    @NotNull(message = "参数id不能为空", groups = {Update.class})
    @Min(message = "cid不合法", value = 0, groups = {Update.class})
    private Integer cId;
    private Integer cMethodId;
    /**
     * 参数名
     */
    private String cName;
    /**
     * 参数类型
     */
    private String cType;
    private String cDesc;
    @NotBlank(message = "要更新的描述不能为空", groups = {Update.class})
    private Integer cIndex;
    private Date cCreateTime;
    private Date cUpdateTime;

    public Parameter(Integer cMethodId, String cName, String cType) {
        this.cMethodId = cMethodId;
        this.cName = cName;
        this.cType = cType;
    }

    public Parameter() {
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Parameter)) return false;
        Parameter parameter = (Parameter) o;
        return Objects.equals(cMethodId, parameter.cMethodId) &&
                Objects.equals(cName, parameter.cName) &&
                Objects.equals(cType, parameter.cType);
    }

    @Override
    public int hashCode() {

        return Objects.hash(cMethodId, cName, cType);
    }
}
